{{- if (.Values.global.enabledModules | has "operator-prometheus-crd") }}
---
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
  name: l2-load-balancer-speaker
  namespace: d8-monitoring
  {{- include "helm_lib_module_labels" (list . (dict "prometheus" "main" "app" "speaker")) | nindent 2 }}
spec:
  jobLabel: app
  podMetricsEndpoints:
    - port: https-metrics
      scheme: https
      bearerTokenSecret:
        name: "prometheus-token"
        key: "token"
      tlsConfig:
        insecureSkipVerify: true
      relabelings:
        - regex: endpoint
          action: labeldrop
        - targetLabel: tier
          replacement: cluster
        - sourceLabels: [__meta_kubernetes_pod_ready]
          regex: "true"
          action: keep
  selector:
    matchLabels:
      app: speaker
  namespaceSelector:
    matchNames:
      - d8-{{ .Chart.Name }}
{{- end }}
